package com.qimo.service.Impl;

import com.qimo.dao.UserDao;
import com.qimo.model.User;
import com.qimo.service.UserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service("userService")
public class UserServiceImpl implements UserService {

    @Resource
    private UserDao userDao;

    public User selectUser(String userName) {
        return this.userDao.selectUser(userName);
    }

    public int  insertUser(User user) {
      return this.userDao.insertUser(user);
    }

    public int update(int userId, String userShowName, String userRealName, int Sex, String Address, String Email, String Telephone, String Mobile, String newPassWord) {
       if(this.userDao.update(userId,userShowName,userRealName,Sex,Address,Email,Telephone,Mobile)>0)
       {
           System.out.println(newPassWord);
           if(newPassWord==null)
               return 1;
           else
               return this.userDao.updatePassWord(userId,newPassWord);
       }
       return 0;

    }

}
